<template>
  <div class="hello">
    我是微应用模块一
    <h1>{{ msg }}</h1>
    <p>qiankun 主应用带过来的消息：{{microInfo}}</p>
    <button @click="handleActions">子应用按钮</button>
  </div>
</template>
 
<script>
import actions from '../../utils/actions'
export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: 'VUE2-APP 子应用',
      microInfo: {}
    }
  },
  mounted() {
    // 注册观察者函数
    actions.onGlobalStateChange(state => {
      console.log('子应用的观察函数：', state)
      this.microInfo = state
    }, true)
  },
  methods: {
    handleActions() {
      actions.setGlobalState({
        msg: `子应用传递过来消息，子组件修改成功`,
      })
    }
  },
}
</script>
 
<style scoped>
</style>